package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * account表 修改记录
 */
public class Demo03 {
    public static void main(String[] args) {
        Connection con =null;
        Statement sta =null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql:///db2","root","myroot");
            String sql= "update account set balance= 4000 where id=3";
            sta = con.createStatement();
            int i = sta.executeUpdate(sql);
            System.out.println(i);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                sta.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
